<template>
  <div :style="{ width }" class="my">
    <div class="my-header">
      <div class="header-left">
        <template v-if="$slots.prefix">
          <div class="icon1">
            <slot name="prefix"></slot>
          </div>
        </template>
        <div v-else class="icon2">
          <i class="prefix-icon" />
        </div>
        <span class="title">
          {{ title }}
        </span>
      </div>
      <div class="header-right suffix">
        <template v-if="$slots.suffix">
          <slot name="suffix"></slot>
        </template>
        <i v-else class="suffix-icon" />
      </div>
    </div>
    <div class="my-body">
      <slot></slot>
    </div>
  </div>
</template>

<script>
export default {
  name: "my",
  props: {
    title: {
      type: String,
      require: true,
    },
    width: {
      type: String,
      default: "100%",
    },
    top: String,
    left: String,
    right: String,
    bottom: String,
  },
};
</script>
<style lang="less" scoped>
.my {
  display: flex;
  flex-direction: column;
  z-index: 99;

  .my-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    border-bottom: 1px solid #666;
    margin-top: 10px;

    .header-left {
      flex: 1;
      display: flex;
      align-items: center;

      .icon1 {
        border-bottom: 2px solid #29f0f1;
        padding-bottom: 5px;
        margin-right: 10px;
      }

      .icon2 {
        border-bottom: 2px solid #29f0f1;
        padding-bottom: 5px;
        margin-right: 10px;

        .prefix-icon {
          display: inline-block;
          content: "";
          width: 30px;
          height: 30px;
          background: url("../../assets/images/Common/icon-prefix.png") no-repeat;
          background-size: 100% 100%;
        }
      }

      .title {
        font-weight: bold;
        color: #fff;
        overflow: hidden;
        text-overflow: ellipsis;
        white-space: nowrap;
        font-size: 17px;
        margin-bottom: 5px;
      }
    }

    .header-right {
      .suffix-icon {
        display: inline-block;
        content: "";
        width: 45px;
        height: 20px;
        background: url("../../assets/images/Common/subtitle-suffix.png") no-repeat;
        background-size: 100% 100%;
      }
    }

    .prefix {
      &-icon {
        display: inline-block;
        content: "";
        width: 40px;
        height: 16px;
        background: url("../../assets/images/Common/subtitle-suffix.png") no-repeat;
        background-size: 100% 100%;
      }
    }
  }
}
</style>
